package tfts

import "fmt"

func (f *Fight) Vanguard(active int) *Fight {
	percent := 0
	switch active {
	case 2:
		percent = 16
	case 4:
		percent = 32
	case 6:
		percent = 40
	default:
		panic("Invalid active number")
	}
	shield := fmt.Sprintf("%d*hp", percent)
	f.PrevCall(func(fight *Fight) {
		fight.Shield("Vanguard", shield, 10)
	})
	a := NewAction(f).Once(8).On(TimeGoE)
	a.name = "Vanguard"
	a.Shield = shield
	a.duration = 10
	NewAction(f, DR(12)).Repeat(1).On(DamagedE).Condition(func(fight *Fight) bool {
		for _, sh := range f.shields {
			if sh.valid() {
				return true
			}
		}
		return false
	})
	return f
}

func (f *Fight) Shapeshifter(active int) *Fight {
	percent := 0
	switch active {
	case 2:
		percent = 10
	case 4:
		percent = 18
	case 6:
		percent = 27
	default:
		panic("Invalid active number")
	}
	f.Add(HpAmp(percent))
	NewAction(f).Once(1).On(BeforeCastE).AddCall("Shapeshifter", func(fight *Fight) {
		grow := f.maxHp * 2 * percent / 100
		f.Health += grow
		f.Add(HpAmp(2 * percent))
		traceLog("%4.1f秒:[%s]触发, 增长生命值%d\n", fight.current(), "Shapeshifter", grow)
	})
	return f
}

func (f *Fight) Bastion(active int) *Fight {
	switch active {
	case 2:
		f.Add(AR(0))
	case 4:
		f.Add(AR(0))
	case 6:
		f.Add(AR(0))
	default:
		panic("Invalid active number")
	}
	return f
}

func (f *Fight) Bruiser(active int) *Fight {
	f.Add(HP(100))
	switch active {
	case 2:
		f.Add(HpAmp(0))
	case 4:
		f.Add(HpAmp(0))
	case 6:
		f.Add(HpAmp(0))
	default:
		panic("Invalid active number")
	}
	return f
}

func (f *Fight) prevShield(name, shield string) *Fight {
	f.PrevCall(func(fight *Fight) {
		fight.Shield(name, shield, 10)
	})
	return f
}

func (f *Fight) prevBuff(name string, meta *buffMeta) *Fight {
	f.PrevCall(func(fight *Fight) {
		meta.attach(f)
		traceLog("%4.1f秒:[%s]触发, 添加Buff %s\n", fight.current()+0.01, name, meta.String())
	})
	return f
}
